package com.lcz.cloud_note.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;

import com.lcz.cloud_note.entity.User;
import com.lcz.cloud_note.service.UserService;
import com.lcz.cloud_note.util.NoteResult;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")//匹配请求路径
public class UserLoginController {
	@Resource
	private UserService userService;
	
	@RequestMapping("/login.do")//匹配请求
	public NoteResult<User> login(String name,String password){
		//调用UserService处理登录请求
		System.out.println(name+","+password);
		NoteResult<User> result = userService.checkLogin(name, password);
		return result;
	}

	@RequestMapping("/change.do")
	public NoteResult<Object> change(String userName,String last_password,String final_password){
		NoteResult<Object> result = userService.changeUser(userName, last_password, final_password);
		return result;
	}

	@RequestMapping("/add.do")
	public NoteResult<Object> add(String name,String password,String nick) {
		//调用userService处理注册请求
		NoteResult<Object> result = userService.addUser(name, password, nick);
		System.out.println(result);
		return result;
	}
}
